<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<html>
<script type='text/javascript' src='//g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
<script type='text/javascript' src='//g.alicdn.com/msui/sm/0.6.2/js/sm.min.js' charset='utf-8'></script>
<script type='text/javascript' src='//g.alicdn.com/msui/sm/0.6.2/js/sm-extend.min.js' charset='utf-8'></script>
<body>
<h2>Hello World!</h2>
<form method="post" action="shangchuanftp" enctype="multipart/form-data" >
    <input type="file" name="file" />
    <input type="submit" value="上传" />
</form>

<div>
    <input id="name" type="text" />
    </br>
    <input id="pwd" type="text" />
    </br>
    <input id="age" type="text" />
    </br>
    <input type="file" name="file" id="file-img"/>
    <br>
    <input type="submit" id="submit" value="提交" />
</div>
<script>
    $(function () {
        $("#submit").click(function () {
            var name=$("#name").val();
            var pwd=$("#pwd").val();
            var age=$("#age").val();
            // 获取上传的图片文件流  [0].files ssss
            var fileImg=$("#file-img")[0].files[0];
            var ssm={};
            ssm.name=name;
            ssm.pwd=pwd;
            ssm.age=age;
            // 生成表单对象，用于接收参数并传递给后台
            var formData = new FormData();
            formData.append("ssm",JSON.stringify(ssm));
            console.log(JSON.stringify(ssm));
            formData.append("fileImg",fileImg);
            console.log(fileImg);
            $.ajax({
                url : "/tijiao",
                type : 'POST',
                data : formData,
                contentType : false,
                processData : false,
                cache : false,
                success : function(data) {
                    alert("chenggong!");
                    if (data.success) {
                        $.toast('提交成功！');
                    }
                }
            });
        })
    })


</script>
</body>
</html>
